package vistas;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import javax.swing.JButton;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import clases.Profesor;
import clases.Seccion;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JDSeccion extends javax.swing.JDialog {
	private JPanel jPSeccion;
	private JLabel jLabelNumeroSeccion;
	private JTextField jTextNumeroSeccion;
	private AbstractAction abstractAction1;
	private AbstractAction abstractAction2;
	private JButton jButtonSalir;
	private JButton jButtonRegistrar;
	private Seccion _seccion;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				JDSeccion inst = new JDSeccion(frame, new Seccion());
				inst.setVisible(true);
			}
		});
	}
	
	public JDSeccion(JFrame frame,Seccion secion) {
		super(frame);
		initGUI();
		_seccion = secion;
	}
	
	private void initGUI() {
		try {
			setTitle("Registro de la Seccion");
			{
				jPSeccion = new JPanel();
				getContentPane().add(jPSeccion, BorderLayout.CENTER);
				jPSeccion.setLayout(null);
				{
					jLabelNumeroSeccion = new JLabel();
					jPSeccion.add(jLabelNumeroSeccion);
					jLabelNumeroSeccion.setText("Numero de la Seccion");
					jLabelNumeroSeccion.setBounds(38, 77, 199, 34);
				}
				{
					jTextNumeroSeccion = new JTextField();
					jPSeccion.add(jTextNumeroSeccion);
					jTextNumeroSeccion.setBounds(280, 84, 51, 21);
				}
				{
					jButtonRegistrar = new JButton();
					jPSeccion.add(jButtonRegistrar);
					jButtonRegistrar.setText("Registrar");
					jButtonRegistrar.setBounds(67, 199, 119, 29);
					jButtonRegistrar.setAction(getAbstractAction1());
				}
				{
					jButtonSalir = new JButton();
					jPSeccion.add(jButtonSalir);
					jButtonSalir.setText("Volver");
					jButtonSalir.setBounds(223, 200, 108, 28);
					jButtonSalir.setAction(getAbstractAction2());
					jButtonSalir.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButtonSalir.actionPerformed, event="+evt);
							//TODO add your code for jButtonSalir.actionPerformed
						//	System.exit(0);	
						}
					});
				}
			}
			setSize(400, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private AbstractAction getAbstractAction1() {
		if(abstractAction1 == null) {
			abstractAction1 = new AbstractAction("Registrar", null) {
				public void actionPerformed(ActionEvent evt) {
					if(jTextNumeroSeccion.getText().equals("")){
						JOptionPane.showMessageDialog(new JFrame(),"Debe llenar el campo numero","Registro de la Seccion",JOptionPane.WARNING_MESSAGE);
						return;
					}
				
				_seccion.set_numero(jTextNumeroSeccion.getText());
				JOptionPane.showMessageDialog(new JFrame(),"Seccion creada con exito","Registro de la Seccion",JOptionPane.INFORMATION_MESSAGE);
				
				}
			};
		}
		return abstractAction1;
	}
	
	private AbstractAction getAbstractAction2() {
		if(abstractAction2 == null) {
			abstractAction2 = new AbstractAction("Volver", null) {
				public void actionPerformed(ActionEvent evt) {
					dispose();
				}
			};
		}
		return abstractAction2;
	}

}
